package org.meituan0927;


import org.junit.jupiter.api.Test;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * @author Zane
 * @date 2021/9/27 9:41
 */
public class MeituanTest {

    /**
     * 获取商家id必备信息
     */
    @Test
    public void getMerchantIdTest() throws Exception {
        String url = "http://i.meituan.com/s/chongqing-";
        String merchantName = "满记甜品（北城天街二店）";
        String userIdAndToken = "请查看文章自行获取";
        String finalUrl = url + java.net.URLEncoder.encode(merchantName, "UTF-8") + userIdAndToken;
        String merchantId = MeituanUtils.getMerchantId(finalUrl);
        System.out.println("商家id------------------>" + merchantId);
        getMerchantComment(merchantId, userIdAndToken);
    }

    @Test
    public void getMerchantComment(String merchantId, String userIdAndToken) throws Exception {
        String finalUrl = "http://i.meituan.com" + merchantId + "/feedbacks" + userIdAndToken;
        System.out.println("评价链接------------------>" + finalUrl);
        MeituanUtils.getMerchantCommentPage(finalUrl);
    }

    /**
     * java8时间类型转换，测试
     */
    @Test
    public void changeTime() {
        String time = "2021-09-11";
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDate toLocalTime = LocalDate.parse(time, df);
        System.out.println(toLocalTime);
    }
}
